265C - Escape from Stones - CodeForces Solution


greedy implementation *1200

Please click on ads to support us..

C++ Code:

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <cstring>
#include <set>
#include <numeric>
#include <array>
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define sz(x) (int)x.size()
#define debug(x) cout<<#x<<" = "<<x<<endl;
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define setbits(x) __builtin_popcountll(x)
#include <stack>
#define unsigned int 
using namespace std;
#include <iostream>
#include <queue>
#include <deque>
#include <vector>
#include <functional>
using namespace std;

#define PI 3.14159265358979323846264
#define ii pair<int,int>
#define iii pair<int, pair<int, int>>

 
using namespace std;

int go(string input, char c)
{
    int n;
    return 0;
}
struct Node
{
    int val;
    Node* next;
    
    Node(int val)
    {
        this->val = val;
        next =NULL;
    }
};
void solve() 
{
    string input;
    cin>>input;
    int n = input.size();
    vector<int> ans(1, 0);
    for(int i=0;i<n;i++)
    {
        if(input[i]=='r')
            ans.push_back(i+1);
    }
    for(int i=n-1;i>=0;i--)
    {
        if(input[i]=='l')
            ans.push_back(i+1);
    }
    for(int i=1;i<ans.size();i++)
        cout<<ans[i]<<endl;
}

main() {
    IOS;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
    return 0;
}


Comments

Submit
0 Comments
More Questions

Cutting a material
Bubble Sort
Number of triangles
AND path in a binary tree
Factorial equations
Removal of vertices
Happy segments
Cyclic shifts
Zoos
Build a graph
Almost correct bracket sequence
Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix